package gof_003_行为型_Behavioral.gof_005_责任链_ChainOfResponsibility.gof_004_Chain;

public class Role_MeiTuan implements Role_Takeout {
    private int status;

    public Role_MeiTuan(int status) {
        this.status = status;
        switch (status) {
            case 3:
                dispatch();
                break;
            case 7:
                refund();
                break;
            case 9:
                orderOver();
                break;
            case 10:
                redPacket();
                break;
            case 11:
                userEvaluation();
                break;
            default:
                break;
        }
    }

    /**
     * 美团派单
     */
    private void dispatch() {
        int scanner = Utils.scanner("模拟用户定时送达: [1]即时送达\t[2]定时送达");
        if(scanner == 1){
            System.out.println("选择了即时送达");
        }else if (scanner == 2){
            System.out.println("选择了定时送达");

            int i = 3;
            while(i>0){
                System.out.println("等待到明天早上9点送达... " + i);
                Utils.sleep(1);

                i--;
            }
        }

        System.out.println("美团派单给商家...");
        Utils.sleep(1);

        new Role_Business(4);
    }

    /**
     * 订单退款
     */
    private void refund() {
        System.out.println("美团退款中...");
        Utils.sleep(1);
        System.out.println("退款成功！！！");

        new Role_MeiTuan(10);
    }

    /**
     * 订单完成
     */
    private void orderOver() {
        System.out.println("订单完成!!!");
        Utils.sleep(1);

        new Role_MeiTuan(11);
    }




    /**
     * ################################ 分割线 ################################
     */
    /**
     * 用户补偿红包
     */
    private void redPacket() {
        System.out.println("发放补偿红包...");
    }

    /**
     * 用户评价
     */
    private void userEvaluation() {
        System.out.println("用户评价...");
    }

    /**
     * ################################ 分割线 ################################
     */
}